package fr.univ.lille1.server.manager;

import javax.ejb.Remote;

import fr.univ.lille1.server.domain.SessionKey;
import fr.univ.lille1.server.domain.User;

/**
 * @author TagThis
 *
 */
@Remote
public interface SessionKeyManager {
	
	/**
	 * @param id the user id
	 * @return the session key associated to the user
	 */
	SessionKey findSessionKeyByUserId(int id);
	
	/**
	 * create the session key for a certain user
	 * @param user the user which we want to associate the session key
	 * @param sessionKey the session key
	 * @param generateTime the time of the key's generation
	 * @return the instance of the session key
	 */
	SessionKey createSessionKey(User user, String sessionKey,long generateTime);
	
	/**
	 * update the instance of the session key 
	 * @param sessionKey the new instance of the session key
	 * @return the session key updated
	 */
	SessionKey updateSessionKey(SessionKey sessionKey);
	
	/**
	 * generate a new key for a user
	 * @param user the user we want to associate to the session key
	 * @return a session key for the user
	 */
	SessionKey generateNewKey(User user);
	
	/**
	 * check if the client key on the client side is the same as the remote session key
	 * @param clientKey the client key to compare with the remote key
	 * @param user the client
	 * @return true if the client key is the same as the remote key, false otherwise
	 */
	boolean correctSessionKey(String clientKey, User user);	

}